﻿<UserControl x:Class="YouTubePlaylist.Views.YouTubePlayerCtrl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Ctrls="clr-namespace:Radovici.Ctrls;assembly=RadoviciCtrls" 
    xmlns:SharedLibrary="clr-namespace:Radovici.SharedLibrary;assembly=RadoviciSharedLibrary" 
    xmlns:Views="clr-namespace:YouTubePlaylist.Views" 
    xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" 
    xmlns:ContentControls="clr-namespace:Radovici.Ctrls.ContentControls;assembly=RadoviciCtrls" >
    <UserControl.Resources>
        <SharedLibrary:BooleanToVisibilityConverter x:Key="ToVisibilityConverter"/>                
        <Views:IsPlayingConverter x:Key="IsPlayingConverterInstance"/>
        <Style x:Name="WhiteBodyStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="10"/>
        </Style>
        <Style x:Name="WhiteHeaderStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="16"/>
        </Style>
    </UserControl.Resources>
    <ContentControls:DropTarget TargetDataContext="{Binding PlaylistModel}" Function="Set">
        <Border CornerRadius="10" BorderThickness="4" BorderBrush="Black" Background="Black" Padding="10">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="85"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="85"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Button Grid.Row="0" Grid.Column="0" Click="OnPreviousClicked" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" 
                        Visibility="{Binding PlaylistModel.HasPrevious, Converter={StaticResource ToVisibilityConverter}}">
                    <Image Source="Resources/48/media_step_back.png" Height="24"/>
                </Button>
                <Viewbox Grid.Row="0" Grid.Column="1">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"
                            Visibility="{Binding PlaylistModel.HasTracks, Converter={StaticResource ToVisibilityConverter}}">
                        <Button Click="OnPlayPause" Margin="0,0,10,0" VerticalAlignment="Center">
                            <Image Source="{Binding IsPlaying, Converter={StaticResource IsPlayingConverterInstance}}" Height="24"/>
                        </Button>
                        <TextBlock Text="{Binding PlaylistModel.Current.Name}" Margin="0,0,2,0" Style="{StaticResource WhiteHeaderStyle}" VerticalAlignment="Center"/>
                        <TextBlock Text="by" Margin="2,0,2,0" Style="{StaticResource WhiteHeaderStyle}" VerticalAlignment="Center"/>
                        <TextBlock Text="{Binding PlaylistModel.Current.Artist}" Margin="2,0,0,0" Style="{StaticResource WhiteHeaderStyle}" VerticalAlignment="Center"/>
                    </StackPanel>
                </Viewbox>
                <Button Grid.Row="0" Grid.Column="2" Click="OnNextClicked" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" 
                        Visibility="{Binding PlaylistModel.HasNext, Converter={StaticResource ToVisibilityConverter}}">
                    <Image Source="Resources/48/media_step_forward.png" Height="24"/>
                </Button>

                <Viewbox Grid.Row="1" Grid.Column="0" Margin="0,0,10,0" Stretch="Fill">
                    <StackPanel DataContext="{Binding PlaylistModel.Previous}" Orientation="Vertical" Cursor="Hand" MouseLeftButtonUp="OnPreviousClicked"
                            Visibility="{Binding PlaylistModel.HasPrevious, Converter={StaticResource ToVisibilityConverter}}">
                        <TextBlock Text="Previous:" Margin="0,0,0,4" Style="{StaticResource WhiteBodyStyle}"/>
                        <TextBlock Text="{Binding Name}" Margin="0,0,0,4" Style="{StaticResource WhiteBodyStyle}"/>
                        <TextBlock Text="{Binding Artist}" Margin="0,0,0,4" Style="{StaticResource WhiteBodyStyle}"/>
                        <Ctrls:YouTubePictures YouTubeVideo="{Binding SelectedUrl.Url}" Orientation="Vertical"/>
                    </StackPanel>
                </Viewbox>

                <Ctrls:YouTubePlayer x:Name="Player" Grid.Row="1" Grid.Column="1" VideoUrl="{Binding PlaylistModel.Current.SelectedUrl.Url}" AutoPlay="True" ShowInfo="True" Volume="100"
                                          StateChanged="OnYouTubeVideoPlayerStateChanged" IsVisible="{Binding IsPlayerVisible}"/>
                <!--<Ctrls:PornZappPlayer Grid.Column="1" x:Name="Player" VideoUrl="{Binding Current.SelectedUrl.Url}"
                                          IsVisible="{Binding IsPlayerVisible}"
                                          Width="425" Height="350"
                                          Visibility="{Binding Model.IsXXXVersion, Converter={StaticResource ToVisibilityConverter}}"/>-->

                <Viewbox Grid.Row="1" Grid.Column="2" Margin="10,0,0,0" Stretch="Fill">
                    <StackPanel DataContext="{Binding PlaylistModel.Next}" Orientation="Vertical" Cursor="Hand" MouseLeftButtonUp="OnNextClicked"
                            Visibility="{Binding PlaylistModel.HasNext, Converter={StaticResource ToVisibilityConverter}}">
                        <TextBlock Text="Next:" Margin="0,0,0,4" Style="{StaticResource WhiteBodyStyle}"/>
                        <TextBlock Text="{Binding Name}" Margin="0,0,0,4" Style="{StaticResource WhiteBodyStyle}"/>
                        <TextBlock Text="{Binding Artist}" Margin="0,0,0,4" Style="{StaticResource WhiteBodyStyle}"/>
                        <Ctrls:YouTubePictures YouTubeVideo="{Binding SelectedUrl.Url}" Orientation="Vertical"/>
                    </StackPanel>
                </Viewbox>
                
                <!--<Views:PlaylistToolbarCtrl Grid.Row="2" Grid.ColumnSpan="3" Margin="2"/>-->
            </Grid>
        </Border>
    </ContentControls:DropTarget>
</UserControl>
